package info.hexin.redis;

import info.hexin.redis.model.RedisParams;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.Set;

/**
 * Created by infi.he on 2015/5/18.
 */
public  class Main {
    public static void main(String[] args) {

        final String key = "aa";

        final byte[] xx = new byte[1024 * 1024];
        String value1 = new String(xx);
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("app.xml");
        final RedisTemplate redisTemplate = applicationContext.getBean(RedisTemplate.class);

//        for (int i = 0; i < 100; i++) {
//            RedisParams redisParams = new RedisParams();
//            redisParams.setFileName("xxxxx");
//            redisParams.setScore(Double.valueOf(i));
//            redisParams.setContext(xx);
//            redisParams.setAccountId("12321321");
//            redisParams.setTargetAndEquipment("{\"name\":\"a\"}");
//            redisTemplate.opsForZSet().add(key, redisParams, redisParams.getScore());
//        }

        for (int i = 0; i < 10; i++) {
            final int ii = i;
            new Thread() {
                @Override
                public void run() {
                    for (int j = 0; j < 10; j++) {
                        long start = System.currentTimeMillis();
                        Set<RedisParams> set = redisTemplate.opsForZSet().rangeByScore(key, j, j, 0, 2);
                        System.out.println("---- i>>>" + ii + " ; j>>>" + j + "------------------------------------" + (System.currentTimeMillis() - start));
                    }
                }
            }.start();
        }
    }
}
